<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('模块列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            模块名称：<input type="text" name="moduleName"/>
                            <input type="hidden" name="datasourceId" id="datasourceId"/>
                        </li>
                        <li>
                            表前缀：<input type="text" name="tablePrefix"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="tool:module:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()"
               shiro:hasPermission="tool:module:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="tool:module:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="tool:module:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('tool:module:edit')}]];
    var removeFlag = [[${@permission.hasPermi('tool:module:remove')}]];
    var prefix = ctx + "tool/module";
    var datasourceId = GetQueryString("datasourceId");
    $("#datasourceId").val(datasourceId);
    $(function () {
        var options = {
            url: prefix + "/list?datasourceId=" + datasourceId,
            createUrl: prefix + "/add?datasourceId=" + datasourceId,
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "模块",
            showExport: true,
            columns: [{
                checkbox: true
            },
                {
                    field: 'moduleId',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'moduleName',
                    title: '模块名称',
                    sortable: true
                },
                {
                    field: 'tablePrefix',
                    title: '表前缀',
                    sortable: true
                },
                {
                    field: 'moduleSort',
                    title: '排序',
                    sortable: true
                },
                {
                    field: 'updateBy',
                    title: '更新者',
                    sortable: true
                },
                {
                    field: 'updateTime',
                    title: '更新时间',
                    sortable: true
                },
                {
                    field: 'remark',
                    title: '备注',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="createMenuItem(\'/tool/datasource/table?tablePrefix='+row.tablePrefix+'&datasourceId=' + row.datasourceId + '\',\'' + row.moduleName + '-表\')"><i class="fa fa-edit"></i>数据库表</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="createMenuItem(\'/tool/datasource/viewDoc?tablePrefix='+row.tablePrefix+'&datasourceId=' + row.datasourceId + '\',\'' + row.moduleName + '-表\')"><i class="fa fa-edit"></i>预览WORD</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.moduleId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.moduleId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    // 删除信息
    function viewWord() {

        createMenuItem('/tool/datasource/viewDoc?tablePrefix='+tablePrefix+'&datasourceId='+datasourceId,"预览");
    }
</script>
</body>
</html>